<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
$slide = $this->db->select()->from('slider')->order_by('slide_id', 'desc')->get()->row_array();
if (sizeof($slide) > 0) {
echo "<div class='small-line'>";
	echo "<a class='blue-link' href='/stocks-terms/' target='_blank'>Условия акции</a>&nbsp;&nbsp;&nbsp;";
	echo "<a class='blue-link' href='/stocks/' target='_blank'>Прошедшие акции</a>";
echo "</div><br class='cc' />";
echo "<div class='main-page-placeholder'>";
	//echo "<img src='/uploads/main_slider/".$slide['slide_id']."/".$slide['slide_image']."' alt='".$slide['slide_title']."' title='".$slide['slide_title']."' />";
	//dump($slide);
	$item = $this->db->select()->from('catalog_items')->where('item_id', $slide['slide_item'])->get()->row_array();
	$images = $this->db->select()->from('catalog_images')->where('photo_item', $slide['slide_item'])->where('photo_main', '1')->get()->row_array();
	$link = $this->catalog_service_model->get_item_link($slide['slide_item']);
echo "<table cellspacing='0' cellpadding='0'>";
	echo "<tr>";
	echo "<td class='text'>";
		echo $slide['slide_text'];
	echo "</td>";
	echo "<td class='item'>";
		echo "<a href='".$link."'>";
		echo "<img src='/uploads/catalog_items/".$images['photo_item']."/small/".$images['photo_file']."' alt='' title='' />";
		echo "</a><br/>";
		echo "<a href='".$link."'>";
			echo $item['item_title'];
		echo "</a>";
	echo "</td>";
	echo "<td class='clock'>";
		echo "<p class='a-center'>";

		$time = $slide['slide_date'] - time();
		if ($time <= 0) {
			echo "Акция завершена";
		} else {
			$days = ceil($time / 86400);

			$e = $days % 10;

			switch ($e) {
				case "1": $ended = "день"; break;
				case "2": $ended = "дня"; break;
				case "3": $ended = "дня"; break;
				case "4": $ended = "дня"; break;
				default: $ended = "дней"; break;
			}
			echo "До окончания акции <span style='color: red;'>".$days."</span> ".$ended;
		}

			echo "";
		echo "</p>";
	echo "</td>";
	echo "</tr>";
	echo "</table>";

echo "</div>";

}
if(sizeof($catalog_parents) > 0){
	$data['pages'] = $catalog_parents;
	$this->load->view('modules/catalog/index', $data);
}
if (sizeof($catalog_news) > 0) {
	echo "<div class='home-page-items'>";
	foreach ($catalog_news as $one) {
		$data['item'] = $one;
		$this->load->view('modules/catalog/one_small_item_homepage', $data);
	}
	echo "</div>";
}
if($homepage['page_show_h1'] == 1){
	echo "<h1>".$homepage['page_title']."</h1>";
}
echo htmlspecialchars_decode($homepage['page_text']);
echo "<p>&nbsp;</p>";
echo "<p>&nbsp;</p>";
if (sizeof($news) > 0) {
	foreach ($news as $one) {
		echo "<div class='mp-one-news'>";
		echo "<div class='wp'>";
			echo "<p><a href='/articles-reviews/".$one['news_id']."/' class='blue-link'>".$one['news_title']."</a></p>";
			echo $one['news_desc'];
		echo "</div>";
		echo "</div>";
	}
	echo "<br class='cc' />";
	echo "<a href='/articles-reviews/' class='fr blue-link'>Все статьи</a>";
	echo "<br class='cc' />";
}
echo '<a class="a-center big" href="/catalog/">Весь каталог продукции</a>';
$slider = $this->slider_model->all();
if(mb_strlen($slider) > 0){
	echo '<a class="a-center brand" href="/brands/" title="Наши бренды">Наши бренды</a>';
	echo '<div class="big_center_slider">';
	echo $slider;
	echo '</div>';
}
